package com.bdqn.ch01.jd;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * TestServlet
 *
 * @aurhor Administrator  whs
 * @since 2024/7/1
 */
@WebServlet(urlPatterns = "/TestServletJD" )
public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");

        User user = null;

        user = SimpleBeanConvertor.parseRequest(request, User.class);

        System.out.println(user);

        /**
         * 查询到的数据为：
         * User{id=1, username='帅帅', ok=true, sex=男, birthday=Tue Jul 19 00:00:00 CST 2005, salary=10000.0, intTechs=[1, 2, 3, 4, 5], strTechs=[Java, C++, Python, HTML]}
         */


    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}
